package com.bcxj.servicemap.controller;

import com.bcxj.internalcommon.dto.ResponseResult;
import com.bcxj.internalcommon.response.TerminalResponse;
import com.bcxj.internalcommon.response.TrsearchResponse;
import com.bcxj.servicemap.service.TerminalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName: TerminalController
 * Package: com.bcxj.servicemap.controller
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/10/31 22:43
 * @Version 1.0
 * @Since 1.0
 */
@RestController
@RequestMapping("/terminal")
public class TerminalController {

    @Autowired
    private TerminalService terminalService;

    /**
     * 添加终端
     * @return
     */
    @PostMapping("/add")
    public ResponseResult addTerminal(@RequestParam String name, @RequestParam String desc) {
        return terminalService.add(name, desc);
    }


    /**
     * 搜索终端
     * @param center
     * @param radius
     * @return
     */
    @PostMapping("/arroundsearch")
    public ResponseResult<List<TerminalResponse>> arroundsearch(@RequestParam String center, @RequestParam String radius) {
        return terminalService.arroundSearch(center, radius);
    }


    /**
     * 终端的轨迹的统计
     * @param tid
     * @param startTime
     * @param endTime
     * @return
     */
    @PostMapping("trsearch")
    public ResponseResult<TrsearchResponse> trsearch(@RequestParam String tid, @RequestParam Long startTime, @RequestParam Long endTime ) {
        return terminalService.trsearch(tid, startTime, endTime);
    }
}
